import Vue from 'vue'
// 导入router插件
import VueRouter from 'vue-router'
// 导入登录注册组件
const Reg = () => import('@/views/Reg')
const Login = () => import('@/views/Login')
const Main = () => import('@/views/Main/Main.vue')
const Home = () => import('@/views/Home.vue')
const Userinfo = () => import('@/views/Main/User/UserInfo.vue')
const UserAvatar = () => import('@/views/Main/User/UserAvatar.vue')
const UserPwd = () => import('@/views//Main/User/UserPwd.vue')
const ArtCate = () => import('@/views/Main/Menus/Article/ArtCate.vue')
const Artlist = () => import('@/views/Main/Menus/Article/Artlist.vue')
// 安装插件
Vue.use(VueRouter)

const routes = [
  { path: '/reg', component: Reg },
  { path: '/login', component: Login },
  {
    path: '/',
    component: Main,
    redirect: '/home',
    children: [
      { path: 'home', component: Home },
      { path: 'user-info', component: Userinfo },
      { path: 'user-avatar', component: UserAvatar },
      // 重置密码的子路由规则
      { path: 'user-pwd', component: UserPwd },
      { path: 'art-cate', component: ArtCate },
      { path: 'art-list', component: Artlist }
    ]
  }
]
// 实例化router插件
const router = new VueRouter({
  routes
})

export default router
